﻿using System;

namespace l1cs_cl.client.receivepackets
{
    // ログインステータスを取得する
    public class R_LoginResult : ReceiveBasePacket
    {
        public int stateLogin;
        public String sStatus;

        const int REASON_LOGIN_OK = 0x00;
        const int REASON_ACCOUNT_IN_USE = 0x16;
        const int REASON_ACCOUNT_ALREADY_EXISTS = 0x07;
        const int REASON_ACCESS_FAILED = 0x08;
        const int REASON_USER_OR_PASS_WRONG = 0x08;
        const int REASON_PASS_WRONG = 0x08;

        public R_LoginResult( byte[] abyte0 )
            : base( abyte0 )
        {
            if ( abyte0 != null )
            {
                stateLogin = readC();

                if ( REASON_LOGIN_OK == stateLogin )
                {
                    sStatus = "ログインOK";
                }
                else if ( REASON_ACCOUNT_IN_USE == stateLogin )
                {
                    sStatus = "REASON_ACCOUNT_IN_USE";
                }
                else if ( REASON_ACCOUNT_ALREADY_EXISTS == stateLogin )
                {
                    sStatus = "REASON_ACCOUNT_ALREADY_EXISTS";
                }
                else if ( REASON_ACCESS_FAILED == stateLogin )
                {
                    sStatus = "REASON_ACCESS_FAILED";
                }
                else if ( REASON_USER_OR_PASS_WRONG == stateLogin )
                {
                    sStatus = "REASON_USER_OR_PASS_WRONG";
                }
                else if ( REASON_PASS_WRONG == stateLogin )
                {
                    sStatus = "REASON_PASS_WRONG";
                }
            }
        }
    }
}
